const {
	Service
} = require('uni-cloud-router')
const {empty,typeOf} = require('../methods/index.js')

module.exports = class scheduleService extends Service {
	constructor(ctx) {
		super(ctx)
		this.dbCmd = this.db.command
		this.user = this.db.collection('uni-id-users')
		this.hrCourse = this.db.collection('hr-course')
		this.hrCollege = this.db.collection('hr-college')
		this.teachingClass = this.db.collection('teaching-class')
		this.hrUserSchedule = this.db.collection('hr-userSchedule')
	}
	
	/*
	* 搜索学生 
	*/
	async searchStudent(){
		return await this.user.where({
			['role']:'STUDENT'
		}).get().then((res)=>{
			let list = []
			return list = res.data.map((item)=>{
				let {username , nickname} = item
				 return { value: username, label: `${username}-${nickname}` };
			})
		})
	}
	
	/**
	 * 
	 */
	async loadStudent(where){
		return await this.user.where(where).field({'username':true,'nickname':true}).get().then((res)=>{
			return res.data
		})
	}

}